#include<stdio.h>
unsigned invert(unsigned,int,int);
int main()
{
  unsigned x;
  int p,n;
  printf("enter a number");
  scanf("%u",&x);
  printf("enter the position to start reading");
  scanf("%d",&p);
  printf("enter the number of bits to be read");
  scanf("%d",&n);
  printf("the edited number is %u",invert(x,p,n));
  return 0;
}

unsigned invert (unsigned x,int p,int n)
{
  return ((((~(~0 << n))<<p+1-n) & ~x) + ((~((~(~0 << n))<<p+1-n)) &x));
} 
